

using System.Linq;
using Abp.Authorization;
using Abp.Configuration.Startup;
using Abp.Localization;
using Abp.MultiTenancy;
using JYJ.AiYard.Authorization;

namespace JYJ.AiYard.StationManagement.TbYardPayDayNightNFs.Authorization
{
    /// <summary>
    /// 权限配置都在这里。
    /// 给权限默认设置服务
    /// See <see cref="TbYardPayDayNightNFPermissions" /> for all permission names. TbYardPayDayNightNF
    ///</summary>
    public class TbYardPayDayNightNFAuthorizationProvider : AuthorizationProvider
    {
        private readonly bool _isMultiTenancyEnabled;

		public TbYardPayDayNightNFAuthorizationProvider()
		{

		}

        public TbYardPayDayNightNFAuthorizationProvider(bool isMultiTenancyEnabled)
        {
            _isMultiTenancyEnabled = isMultiTenancyEnabled;
        }

        public TbYardPayDayNightNFAuthorizationProvider(IMultiTenancyConfig multiTenancyConfig)
        {
            _isMultiTenancyEnabled = multiTenancyConfig.IsEnabled;
        }

		public override void SetPermissions(IPermissionDefinitionContext context)
		{
			// 在这里配置了TbYardPayDayNightNF 的权限。
			var pages = context.GetPermissionOrNull(AppLtmPermissions.Pages) ?? context.CreatePermission(AppLtmPermissions.Pages, L("Pages"));


			var payparams = pages.Children.FirstOrDefault(p => p.Name == AppPermissions.Pages_YardManage) ??
							pages.CreateChildPermission(AppPermissions.Pages_YardManage, L("Yard_Management"));

			var administration = payparams.Children.FirstOrDefault(p => p.Name == AppPermissions.Pages_YardManage_ChargingStandard) ?? payparams.CreateChildPermission(AppPermissions.Pages_YardManage_ChargingStandard, L("Yard_ChargingStandard"));

			var entityPermission = administration.CreateChildPermission(TbYardPayDayNightNFPermissions.Node, L("TbYardPayDayNightNF"));
			entityPermission.CreateChildPermission(TbYardPayDayNightNFPermissions.Query, L("QueryTbYardPayDayNight"));
			entityPermission.CreateChildPermission(TbYardPayDayNightNFPermissions.Create, L("CreateTbYardPayDayNight"));
			entityPermission.CreateChildPermission(TbYardPayDayNightNFPermissions.Edit, L("EditTbYardPayDayNight"));
			entityPermission.CreateChildPermission(TbYardPayDayNightNFPermissions.Delete, L("DeleteTbYardPayDayNight"));
			entityPermission.CreateChildPermission(TbYardPayDayNightNFPermissions.BatchDelete, L("BatchDeleteTbYardPayDayNight"));

		}

		private static ILocalizableString L(string name)
		{
			return new LocalizableString(name, AppConsts.LocalizationSourceName);
		}
    }
}